package chapter6;

import java.util.Scanner;

/****************************************************************
 * Author：icynlau
 * Description: 格式化整数
 * Date:2021/4/6
 * ***************************************************************
 */
public class exc6_37 {
	
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		
		System.out.print("Enter a number and a width: ");
		int number=input.nextInt();
		int width=input.nextInt();
		
		System.out.print(format(number,width));
		
	}
	
	public static String format(int number,int width) {
		
		String s=String.valueOf(number);
		
		if(s.length()<=width) {
			int n=width-s.length();
			for(int i=0;i<n;i++) {
				s='0'+s;
			}
		}
		
		return s;
		
	}

}
